package com.lz.message.redis.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;

import com.lz.message.redis.Consumer;
import com.lz.message.redis.MessageCopy;

@Configuration
public class MessageConfig {
	
	@Value("${redis.msg.list}")
	private String msgList;
	
	@Value("${redis.msg.msgzset}")
	private String msgZset;
	
	@Bean
	StringRedisTemplate template(RedisConnectionFactory connectionFactory) {
		return new StringRedisTemplate(connectionFactory);
	}
	
	@Bean
	Consumer consumer(StringRedisTemplate stringRedisTemplate) {
		return new Consumer(stringRedisTemplate,msgList);
	}
	
	@Bean
	MessageCopy messageCopy(StringRedisTemplate stringRedisTemplate) {
		return new MessageCopy(stringRedisTemplate, msgList, msgZset);
	}
}
